﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="imgareaselect.aspx.cs" Inherits="jsselect" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="jquery.imgareaselect-0.9.8/css/imgareaselect-default.css" rel="stylesheet" type="text/css" />
    <script src="script/jquery-1.6.2.js" type="text/javascript"></script>
    <script src="jquery.imgareaselect-0.9.8/scripts/jquery.imgareaselect.dev.js" type="text/javascript"></script>
    <script type="text/javascript">
        function preview(img, selection) {
            var scaleX = 100 / (selection.width || 1);
            var scaleY = 100 / (selection.height || 1);

            $('#ferret + div > img').css({
                width: Math.round(scaleX * 400) + 'px',
                height: Math.round(scaleY * 300) + 'px',
                marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
                marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
            });
        }

        $(document).ready(function () {
            $('<div><img src="ferret.jpg" style="position: relative;" /><div>')
        .css({
            float: 'left',
            position: 'relative',
            overflow: 'hidden',
            width: '100px',
            height: '100px'
        })
        .insertAfter($('#ferret'));

            $('#ferret').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div style="width:710px;height:340px;border:1px solid #bcbcbc">
            <img id="ferret" src="img/focus_flr_20121017.jpg" />
        </div>
    </div>
    </form>
</body>
</html>
